home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / qlib.exe / SYSTEM.DOC < prev    next >
Encoding:
Text File  |  1992-04-22  |  16.1 KB  |  515 lines

  1.      QLIB's SYSTEM routines detect the presence or status of PC hardware
  2.      or software.  Monitor type, co-processor presence, CPU speed and keyboard
  3.      toggles may be determined, CPU speed toggle and keyboard toggles may be
  4.      set.  CTRL, ALT and SHIFT key status may also be monitored, and the
  5.      software enviornment may be determined.
  6.  
  7.  
  8.  
  9.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  10.  
  11.      Subroutines: CapsOFF, CapsON
  12.      object file: kbd2.obj
  13.  
  14.           Simplified controls to toggle the CapsLock key.  See also
  15.      GetKBDToggle and SetKBDToggle.
  16.  
  17.      Example:
  18.           CALL CapsON         ' this turns Caps Lock on
  19.  
  20.  
  21.  
  22.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  23.  
  24.     Function: oops% = DOSError
  25.     object file: q$error.obj
  26.  
  27.     DOSError returns an error flag resulting from the most recent QLIB
  28.     subroutine which updates the DOS error flag (see FLoad in DISK.DOC).
  29.     NOTE: not all QLIB subroutines update DOSError!!
  30.  
  31.     common MS-DOS error codes are:
  32.  
  33.     2 = file not found
  34.     3 = path not found
  35.     4 = too many open files
  36.     5 = access denied (file may be read-only or a subdirectory
  37.                        or subdirectory not empty)
  38.     8 = insufficient memory
  39.     19= disk is write-protected
  40.  
  41.     Example:
  42.      REM $INCLUDE: '\qb4\qlib.bi'
  43.      filename$ = "\ramfont\italics.fnt" + CHR$(0)
  44.      iseg% = fload (filename$)
  45.      IF DOSError THEN
  46.          .
  47.          .
  48.          .              ; error handling code
  49.  
  50.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  51.  
  52.     Subroutine: EGAinfo(crt%, memory%)
  53.     object file: egainfo.obj
  54.  
  55.          EGAinfo determines the type of monitor and amount of memory
  56.     installed on an EGA card.  Crt% = 0 if a monochrome monitor is
  57.     attached to the EGA card, -1 if an RGB color monitor, and crt% = 1
  58.     if the monitor is an Enhanced or Mutli-scan monitor.  Memory% returns
  59.     the kbytes installed on the card.  If no EGA is installed, memory% = 0.
  60.  
  61.     Example:
  62.          CALL EGAinfo(crt%, memory%)
  63.  
  64.  
  65.  
  66.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  67.  
  68.     Function: a$ = EXEName$()
  69.     object files: exename.obj (strncpy.obj)
  70.  
  71.     requires DOS version 3.0 or later
  72.  
  73.          EXEName$ returns the full drive and path name of the currently
  74.     executing program.  When developing programs within the QB or QBX
  75.     development enviornment, EXEName$ returns something like:
  76.  
  77.     C:\QB4\QB.EXE
  78.  
  79.     Example:
  80.     REM $INCLUDE: 'qb4\lib\qlib.bi'
  81.     PRINT EXEName$                   ' prints name of program
  82.  
  83.  
  84.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  85.  
  86.     Subroutine: FindMONO(crt%)
  87.     object files: findmono.obj (find6845.obj, egainfo.obj, q$herc.obj)
  88.  
  89.          FindMONO determines if a monochrome monitor is installed.
  90.     GetCRT (below) determines the default monitor; FindMONO will
  91.     find an MDA or HGC monitor in single- or dual-monitor setups
  92.     whether the monochrome monitor is default or not.  Crt% = 0 if
  93.     MDA, 128 or greater if HGC or compatible, and -1 if no monochrome
  94.     installed.
  95.  
  96.     Example:
  97.          CALL FindMONO(crt%)
  98.  
  99.  
  100.  
  101.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  102.  
  103.     Function: Floppies
  104.     object file: floppies.obj
  105.  
  106.          FLOPPIES determines the number of floppy drives installed in the
  107.     computer.
  108.  
  109.     Example:
  110.          REM $INCLUDE: 'qlib.bi'
  111.          fdrives = floppies            ' get number of floppy drives
  112.  
  113.  
  114.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  115.  
  116.     Subroutine: GetCPU(cpu%)
  117.     object file: getcpu.obj
  118.  
  119.          Determines the processor in the computer system.  Returns cpu% = 0
  120.     if 8086 or 8088, cpu% = 1 if 80186 or 80188, cpu% = 2 if 286 and
  121.     cpu% = 3 if 386 or 386sx, and cpu% = 4 if 486.
  122.  
  123.     Example:
  124.          CALL GetCPU(cpu%)
  125.          SELECT CASE cpu%
  126.               CASE 0
  127.                 cpu$ = "8086 or 8088"
  128.               CASE 1
  129.                 cpu$ = "80186 or 80188"
  130.               CASE 2
  131.                 cpu$ = "286"
  132.               CASE 3
  133.                 cpu$ = "386"
  134.          END SELECT
  135.  
  136.  
  137.  
  138.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  139.  
  140.     Subroutine: GetCRT(crt%)
  141.     object files: getcrt.obj (q$herc.obj, egainfo.obj)
  142.  
  143.          GetCRT tells you what kind of display is being used.  The returned
  144.     value will be zero if it's MDA or EGA with a monochrome monitor, -1 if
  145.     CGA, 1 if EGA with a color or enhanced color monitor, 2 if MCGA, and if
  146.     VGA, crt% will be 3.  With Hercules or Hercules clones, crt% will be 128
  147.     or greater.  The Hercules Graphics Card Plus returns 144, and the 
  148.     Hercules InColor card returns 208.  See also IsSEVGA, EGAinfo, and
  149.     FindMONO.
  150.  
  151.     Example:
  152.          REM $INCLUDE: 'qlib.bi'
  153.          CALL GetCRT(crt%)
  154.          SELECT CASE crt%
  155.               CASE -1
  156.                    PRINT "CGA Color"
  157.               CASE 0
  158.                    PRINT "Monochrome Display Adapter"
  159.               CASE 1
  160.                    PRINT "EGA"
  161.               CASE 2
  162.                    PRINT "MCGA"
  163.               CASE 3
  164.                    PRINT "VGA"
  165.               CASE 128 TO 208
  166.                    PRINT "Hercules"
  167.          END SELECT
  168.  
  169.  
  170.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  171.  
  172.     Subroutine: GetDOSVer(maj%, min%)
  173.     object file: dosver.obj
  174.  
  175.          GetDOSVer returns the major and minor version numbers of the DOS
  176.     installed.  Maj% is the major version number, i.e., maj% = 3 if DOS 3.xx
  177.     is installed.  Min% is the minor version number, i.e., min% = 21 if DOS
  178.     x.21 is installed.
  179.  
  180.     Example:
  181.      CALL GetDOSVer(maj%,min%)
  182.      REM if maj% < 3 then SHELL may not be reliable
  183.  
  184.  
  185.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  186.  
  187.     Subroutine: GetKBDToggle(kbd%)
  188.     object file: kbd.obj
  189.  
  190.          Returns the status of the keyboard toggles and whether the CTRL, ALT
  191.     or SHIFT keys are pressed.  The code returned by GetKBDToggle is a copy of
  192.     the BIOS keyboard status byte, which must be ANDed to determine which key
  193.     toggles are set.  See also SetKBDToggle.
  194.  
  195.     Example:
  196.          rshift% = 1
  197.          lshift% = 2
  198.          shiftkey% = 3
  199.          ctrl% = 4
  200.          alt% = 8
  201.          scroll% = 16
  202.          numb% = 32
  203.          caps% = 64
  204.          insert% = 128
  205.          
  206.          CALL GetKBDToggle(kbd%)
  207.          IF (kbd% AND rshift%) THEN PRINT "Right Shift pressed"
  208.          IF (kbd% AND lshift%) THEN PRINT "Left Shift pressed"
  209.          IF (kbd% AND shiftkey%) THEN PRINT "Shift Key pressed"
  210.          IF (kbd% AND ctrl%) THEN PRINT "Ctrl Key pressed"
  211.          IF (kbd% AND alt%) THEN PRINT "Alt Key pressed"
  212.          IF (kbd% AND scroll%) THEN PRINT "ScrollLOCK ON"
  213.          IF (kbd% AND numb%) THEN PRINT "NumLOCK ON"
  214.          IF (kbd% AND caps%) THEN PRINT "CapsLOCK ON"
  215.          IF (kbd% AND insert%) THEN PRINT "INSERT ON"
  216.  
  217.  
  218.  
  219.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  220.  
  221.     Subroutine: GetSpeed(speed%)
  222.     object file: speed.obj
  223.  
  224.          Determines whether the system is in "turbo" mode.  Returns 0 if
  225.     CPU is operating at normal speed, 1 if operating at faster CPU speed.
  226.     See also SetSpeed.
  227.  
  228.     Example:
  229.          CALL GetSpeed(speed%)
  230.  
  231.  
  232.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  233.  
  234.      Function: IsSEVGA
  235.      object file: issevga.obj
  236.  
  237.           IsSEVGA determines if a Super EGA or Super VGA graphics
  238.      card is installed.  Systems detected are:
  239.  
  240.      Everex Micro Enhancer EGA
  241.      Paradise EGA 480
  242.      Oak VGA
  243.      Paradise Plus 16 VGA
  244.      Tseng VGA
  245.      Western Digital VGA
  246.  
  247.      Note that IsSEVGA does not determine what kind of monitor is
  248.      connected to the card.  Many Super EGA/VGA cards require a
  249.      multi-frequency monitor to take advantage of the card's extended
  250.      capabilities.
  251.  
  252.      IsSEVGA returns 0 if no supported system is detected.  If a
  253.      Super EGA/VGA is detected, IsSEVGA returns:
  254.  
  255.      Super EGA:    256+1 if Paradise EGA 480
  256.                    256+2 if Everex Micro Enhancer
  257.  
  258.      Super VGA:    768+1 if Paradise Plus 16
  259.                    768+3 if Tseng VGA
  260.                    768+4 if Oak VGA
  261.                    768+5 if Western Digital VGA
  262.  
  263.      Example:
  264.           REM $INCLUDE: 'qlib.bi'
  265.           evga% = IsSEVGA
  266.           if evga% THEN ...  'ask user if he/she has a multi-frequency
  267.                              ' monitor attached to the computer
  268.  
  269.  
  270.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  271.  
  272.      Subroutines: InsertOFF, InsertON
  273.      object file: kbd2.obj
  274.  
  275.           Simplified controls to toggle the Insert key.  See also
  276.      GetKBDToggle and SetKBDToggle.
  277.  
  278.      Example:
  279.           CALL InsertON       ' this turns Insert key on
  280.  
  281.  
  282.  
  283.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  284.  
  285.     Function: KBDType
  286.     object file: kbd1.obj
  287.  
  288.         Detects enhanced (101-key) keyboards.  Returns 1 if 101-key
  289.     keyboard present and supported, 0 if not.  NOTE: KBDType returns 1
  290.     only if the enhanced keyboard is present AND is supported by the
  291.     computer's BIOS.
  292.  
  293.     Example:
  294.          REM $INCLUDE: 'qlib.bi'
  295.          IF KBDType THEN PRINT "Enhanced keyboard attached to system"
  296.  
  297.  
  298.  
  299.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  300.  
  301.      Subroutine: KeyRate(delay%, repeat%)
  302.      object file: keyrate.obj
  303.  
  304.           KeyRate changes the keyboard's "typematic" delay and repeat rate
  305.      on PS/2 and most AT computers.  Delay% (0 - 3) sets the delay time for
  306.      the start of the typematic action.  Repeat% (0 - 31) sets the number
  307.      of repeats per second.  For both delay% and repeat%, 0 gives the fastest
  308.      keyboard action, and the maximum value (delay% = 3, repeat% = 31) gives
  309.      you an unbearably slow keyboard.
  310.  
  311.      Example:
  312.           REM  don't slow me down!!
  313.           delay% = 0: repeat% = 0
  314.           CALL KeyRate(delay%, repeat%)
  315.  
  316.  
  317.  
  318.  
  319.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  320.  
  321.     Function: a% = MathChip
  322.     object file: mathchip.obj
  323.  
  324.          Detects the presence of a math coprocessor in the system.
  325.     Value returned = 0 if not installed, 1 if 8087, 2 if 80287, 3 if 80387.
  326.     DECLARE FUNCTION MathChip%() before using MathChip.  The INCLUDE
  327.     file QLIB.BI does this for you.
  328.  
  329.     Thanks to Marty Borgen for his help debugging MathChip on PS/2 computers.
  330.  
  331.     Example:
  332.          REM $INCLUDE: 'qlib.bi'
  333.          msg$ = "No math coprocessor"
  334.          IF MathChip THEN msg$ = "math coprocessor installed"
  335.          PRINT msg$
  336.  
  337.  
  338.  
  339.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  340.  
  341.     Subroutine: MouseLimit(x0%, y0%, x1%, y1%)
  342.     object file: mouse.obj
  343.  
  344.          MouseLimit confines the mouse's motion to an area limited by
  345.     x0, y0, x1, y1.  Note that the x-dimension is horizontal and the
  346.     y-dimension is vertical, and that both x and y are PIXELS, whether
  347.     the video system is in graphics mode or text mode.
  348.  
  349.     Example:
  350.          REM  keep the mouse out of the right side of the screen
  351.          REM  assume SCREEN 12, 640 x 480 graphics
  352.          x0% = 0: y0% = 0
  353.          x1% = 600: y1% = 479
  354.          CALL MouseLimit(x0%, y0%, x1%, y1%)
  355.  
  356.  
  357.  
  358.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  359.  
  360.     Subroutine: MousePos(x%, y%)
  361.     object file: mouse.obj
  362.  
  363.          Positions the mouse cursor at (x,y).  Note that the x-dimension
  364.     is horizontal and the y-dimension is vertical, and that both x and y
  365.     are PIXELS, whether the video system is in graphics mode or text mode.
  366.  
  367.     Example:
  368.          REM  put the mouse cursor in the upper left corner of the screen
  369.          x% = 0:y% = 0
  370.          CALL MousePos(x%, y%)
  371.  
  372.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  373.  
  374.     Function: buttons% = MouseReady
  375.     object file: mouse.obj
  376.  
  377.          MouseReady determines if the Mouse driver software is loaded,
  378.     and returns the number of mouse buttons if so.
  379.  
  380.     Example:
  381.          REM $INCLUDE: 'qlib.bi'
  382.          buttons% = MouseReady
  383.          IF buttons% THEN PRINT buttons% + " button mouse installed"
  384.  
  385.  
  386.  
  387.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  388.  
  389.     Function: a$ = Path$(n%)
  390.     object files: path.obj (strlen.obj, strncpy.obj)
  391.  
  392.     requires: DOS 3.xx or greater
  393.  
  394.     Path$() is a pseudo array which returns a path from the program's
  395.     enviornment block.  If the length of the string returned by Path$
  396.     is zero, there are no more paths in the enviornment block.
  397.  
  398.     Example:
  399.          REM  the PATH statement in my AUTOEXEC.BAT file looks like this:
  400.          REM  PATH=C:\;C:\MASM;C:\DOS;C:\F77L3;C:\OS386
  401.  
  402.          REM $INCLUDE 'qlib.bi'     ' tell BASIC about the function
  403.          a$ = " ": n% = 0           ' initial conditions for WHILE/WEND
  404.          WHILE LEN(a$) <> 0
  405.          a$ = path$(n%)
  406.          PRINT a$
  407.          n% = n% + 1
  408.          WEND
  409.  
  410.          REM  this prints:
  411.  
  412.          REM  C:\
  413.          REM  C:\MASM
  414.          REM  C:\DOS
  415.          REM  C:\F77L3
  416.          REM  C:\OS386
  417.  
  418.  
  419.  
  420.  
  421.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  422.  
  423.      Subroutines: NumOFF, NumON
  424.      object file: kbd2.obj
  425.  
  426.           Simplified controls to toggle the NumLock key.  See also
  427.      GetKBDToggle and SetKBDToggle.
  428.  
  429.      Example:
  430.           CALL NumON          ' this turns NumLock on
  431.  
  432.  
  433.  
  434.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  435.  
  436.     Function: PrinterError
  437.     object file: prnerror.obj
  438.  
  439.         Determines whether the printer is ready.  PrinterError returns 0 if
  440.     no error is detected.  If the printer is not turned on, or if it is out
  441.     of paper, PrinterError returns -1.  On some printers, -1 is returned if
  442.     the power is on but the printer is not on-line.
  443.  
  444.     Example:
  445.          REM $INCLUDE 'qlib.bi'
  446.          IF PrinterError THEN PRINT "Printer not ready or out of paper"
  447.  
  448.  
  449.  
  450.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  451.  
  452.     Subroutine: PrnScreenOFF
  453.     Subroutine: PrnScreenON
  454.     object file: prnscrn.obj
  455.  
  456.         These subroutines enable or disable the Print Screen key.
  457.  
  458.     Example:
  459.         REM  disable Print Screen
  460.         CALL PrnScreenOFF
  461.  
  462.         REM  turn it back on before ending the program
  463.         CALL PrnScreenON
  464.  
  465.  
  466.  
  467.  
  468.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  469.  
  470.      Subroutines: ScrollOFF, ScrollON
  471.      object file: kbd2.obj
  472.  
  473.           Simplified controls to toggle the Scroll Lock key.  See also
  474.      GetKBDToggle and SetKBDToggle.
  475.  
  476.      Example:
  477.           CALL ScrollON       ' this turns Scroll Lock on
  478.  
  479.  
  480.  
  481.  
  482.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  483.  
  484.     Subroutine: SetKBDToggle(kbd%)
  485.     object file: kbd.obj
  486.  
  487.          Sets the NumLOCK, CapsLOCK, ScrollLOCK and INSERT keyboard toggles.
  488.     See GetKBDToggle.
  489.  
  490.     Example:
  491.          REM  let's be sure the NumLOCK toggle is ON and CapsLOCK is off
  492.       REM  use the constants in GetKBDToggle
  493.  
  494.          CALL GetKBDToggle(kbd%)       ' get present toggles
  495.          kbd% = (kbd% OR numb%)        ' this will set NumLOCK ON
  496.          kbd% = (kbd% AND (NOT caps%)) ' clears CapsLOCK bit
  497.          CALL SetKBDToggle(kbd%)
  498.  
  499.  
  500.  
  501.  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  502.  
  503.     Subroutine: SetSpeed(speed%)
  504.     object file: speed.obj
  505.  
  506.          Sets speed toggle of most "turbo" clone computers.  Speed% = 0 will
  507.     set normal CPU speed, any other value for speed% will set "turbo" speed.
  508.     Should not affect non-turbo computers (such as IBM PC, AT, etc.).  Good
  509.     style suggests that before using this function for the first time, you
  510.     should get the initial speed with GetSpeed and save it.  You should
  511.     then restore the CPU to that original state before exiting the program.
  512.  
  513.     Example:
  514.          CALL SetSpeed(speed%)
  515.